import consola from 'consola';
import chalk from 'chalk';

const { name, version } = require('../../../package');

export const prefix = chalk.bgCyan.bold(`[${name}@${version}]`);

/**
 * 日志打印
 * @description 只用做打印，consola设置相关请勿使用，在此文件配制
 */
const logger = new Proxy(consola, {
  get(target, prop) {
    if (target[prop]) {
      return (...args: any[]) => {
        target[prop](prefix, ...args);
      };
    }
    return () => {
      consola.warn(prefix, 'consola 调用失败');
    };
  }
});

export default logger;
